<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>延迟函数</title>
  <style>
    .box {
      width: 400px;
      height: 400px;
      background-color: rgb(191, 182, 182);
      position: relative;
    }

    span {
      position: absolute;
      right: -3px;
      top: -14px;
      font-size: 20px;
    }

    .content {
      text-align: center;
      line-height: 400px;
    }
  </style>
</head>

<body>
  <div class="box">
    <span>×</span>
    <div class="content">这是广告</div>
  </div>
  <script>
    // 延迟多少秒之后再执行
    // 只执行一次
    const box = document.querySelector('.box')
    setTimeout(function () {
      box.style.display = 'none'
    }, 5000)
  </script>
</body>

</html>